package com.ruoyi.common.enums;

public enum LevelEums {

    ONCE_PER_BATCH(0, "A"),
    ONCE_PER_MONTH(1, "B"),
    ONCE_PER_QUARTER(2, "C"),
    ;

    private final int code;
    private final String description;

    // 构造函数
    LevelEums(int code, String description) {
        this.code = code;
        this.description = description;
    }

    // 获取对应的 code
    public int getCode() {
        return code;
    }

    // 获取对应的描述
    public String getDescription() {
        return description;
    }

    // 根据描述获取对应的 code
    public static int getCodeByDescription(String description) {
        for (LevelEums level : values()) {
            if (level.getDescription().equals(description)) {
                return level.getCode();
            }
        }
        throw new IllegalArgumentException("Unexpected description: " + description);
    }
}
